import { stringify } from 'qs';
import request from '../utils/requests';
import Base64 from 'base-64';
//获取角色信息
// const url = 'http://127.0.0.1:5003/v1';
const url = '/v1';

export async function submitApi(params) {
  return request(url + '/article/submit', {
    method: 'GET',
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(params),
  });
}

export async function searchApi(params) {
  return request(
    url +
      `/article/search?page=${params.page}&count=${params.count}&query=${params.query}&min=${params.min}&max=${params.max}`,
    {
      method: 'GET',
      headers: {
        'Access-Control-Allow-Origin': '*',
        'Content-Type': 'application/json',
      },
    },
  );
}

export async function getArticleApi(params) {
  return request(url + `/article/get/by/${params.id}`, {
    method: 'GET',
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Content-Type': 'application/json',
    },
  });
}

export async function shop(params) {
  return request(url + '/article/shop', {
    method: 'POST',
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(params),
  });
}

export async function gift(params) {
  return request(url + '/order/free', {
    method: 'POST',
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(params),
  });
}
